/**
 * 作者：陈文斌 on 2019/1/7.
 * 邮箱：chen_wennbin@163.com
 * 版本：v1.0
 */

import 'package:flutter/material.dart';
import 'package:crm/constant/constant.dart';
import 'package:crm/model/ClientManager/client_info_model.dart';
import 'package:crm/component/ClientManager/ClientInfo/client_info_section.dart';
import 'package:crm/component/ClientManager/ClientInfo/client_info_tile_section.dart';
import 'package:crm/component/ClientManager/ClientInfo/client_material_tile_section.dart';
import 'package:crm/view/AppBar/custom_app_bar.dart';

const String Title = '客户资料';

class ClientInfoPage extends StatefulWidget {
  final ClientInfoModel clientInfo;

  @override
  ClientInfoPage({
    Key key,
    @required this.clientInfo,
  }) : super(key: key);

  State<StatefulWidget> createState() => _ClientInfoPageState();
}

class _ClientInfoPageState extends State<ClientInfoPage> {
  final List<String> titles = [
    '行业属性',
    '行业类别',
    '信用额度',
    '已用额度',
  ];

  Map<String, String> contents;

  @override
  void initState() {
    contents = {
      '行业属性': widget.clientInfo.industryAttributes ?? '',
      '行业类别': widget.clientInfo.industryClassification ?? '',
      '信用额度': widget.clientInfo.creditLimit ?? '0',
      '已用额度': widget.clientInfo.creditLimitUsed ?? '0',
    };
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: AppColors.PageBackgroundColor,
      appBar: CustomAppBar(
        title: Title,
      ),
      body: ListView(
        children: <Widget>[
          ClientInfoSection(
            clientInfo: widget.clientInfo,
          ),
          Padding(padding: EdgeInsets.only(top: 1)),
          ClientInfoTileSection(
            titles: titles,
            contents: contents,
          ),
          Padding(padding: EdgeInsets.only(top: 10)),
          ClientMaterialTileSection(
            customerId: widget.clientInfo.id,
            customerName: widget.clientInfo.companyName,
            customerType: widget.clientInfo.customerType,
          ),
        ],
      ),
    );
  }
}
